<?php
    class WZ_View extends \Zend_View
    {
        public function __call($method, $args)
        {
            $methodCalled = substr($method, 0, 3);
            if ($methodCalled == 'get') {
                $var = strtolower(substr($method, 3));
                $res = \WZ::get($var);
                if (null === $res) {
                    $res = \WZ::get(substr($method, 3));
                }
                if (null === $res) {
                    $res = \WZ::get(lcfirst(substr($method, 3)));
                }
                if (null === $res) {
                    $res = \WZ_Request::getPost($var);
                }
                if (null === $res) {
                    $res = \WZ_Request::getGet($var);
                }
                if (null === $res) {
                    $res = \WZ_Request::getSession($var);
                }
                if (null === $res) {
                    $res = \WZ_Request::getCookie($var);
                }
                return $res;
            } else if ($methodCalled == 'set') {
                $var = strtolower(substr($method, 3));
                return \WZ::set($var, $putArgs);
            } else {
                $route = \WZ_Route::getInstance();
                $module = $route->getModule();
                $putArgs = (count($args) == 1) ? $args[0] : $args;
                $helperClass = 'WZHelper_' . ucfirst(strtolower($module)) . '_View';
                return $helperClass::$method($putArgs);
            }
        }
    }